<!DOCTYPE html>
<html lang="zh">
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/header :: header(~{::title},~{::link},~{})">

    <title>日报列表</title>
    <link rel="icon" th:href="@{/assets/img/lcxm.ico}" type="image/ico">
    <link rel="stylesheet" th:href="@{/assets/css/common.css}">
</head>
<body class="body">
<!--导航-->
<div th:replace="common/nav :: nav(true)"></div>
<div class="container">
    <div class="row row-nocol">


        <form class="form-inline lookup" role="form" method="post">


            <div class="form-group" style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-startDate">开始日期</label>
                <div class="input-group">
                    <!--/*@thymesVar id="endDate" type="java.util.Date"*/-->
                    <input class="datetime form-control input-sm" id="lookup-startDate" name="startDate" type="text"
                           th:value="${#dates.format(pager.lookup?.startDate, 'yyyy-MM-dd')}"
                           data-date-format="yyyy-mm-dd" data-min-view="2"
                           data-end-date-target="endDate" readonly placeholder="开始日期"/>
                </div>
            </div>

            <div class="form-group" style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-endDate">结束日期</label>
                <div class="input-group">
                    <input class="datetime form-control input-sm" id="lookup-endDate" name="endDate" type="text"
                           th:value="${#dates.format(pager.lookup?.endDate, 'yyyy-MM-dd')}"
                           data-date-format="yyyy-mm-dd" data-min-view="2"
                           data-picker-position="bottom"
                           data-start-date-target="startDate" readonly placeholder="结束日期"/>
                </div>
            </div>

            <div class="form-group" style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-projectId">所属项目</label>
                <div class="input-group">
                    <select class="form-control input-sm select2" id="lookup-projectId" name="projectId"
                            style="max-width: 20em;"
                            data-placeholder="选择所属项目"
                            data-allow-clear="true"
                            th:attr="data-value=${ pager?.lookup?.projectId}"
                            th:attrappend="data-url=${session.principal?.isNormal() ? 'project/mine' : 'project/all'}"
                    >
                        <option value="">所属项目</option>
                    </select>
                </div>
            </div>
            <div class="form-group" style="margin-left: 5px">
                <label class="control-label sr-only" for="lookup-jira">jira号</label>
                <div class="input-group">
                    <input class="form-control input-sm" id="lookup-jira" name="jira" type="text"
                           th:value="${pager.lookup?.jira}" placeholder="jira号"/>
                </div>
            </div>


            <div class="form-group" style="margin-left: 5px" th:if="${!session.principal?.isNormal()}">
                <label class="control-label sr-only" for="lookup-userId">姓名</label>
                <div class="input-group">
                    <select class="form-control input-sm select2" id="lookup-userId" name="userId"

                            data-placeholder="选择用户"
                            data-allow-clear="true"
                            th:attr="data-value=${ pager?.lookup?.userId}"
                            data-url="user/all">
                        <option value="">--选择用户--</option>
                    </select>
                </div>
            </div>
            <div class="form-group pull-right">
                <!--通用排序字段-->
                <input type="hidden" name="sortColumn" th:value="${pager.lookup?.sortColumn}">
                <input type="hidden" name="sortOrder" th:value="${pager.lookup?.sortOrder}">

                <button type="submit" class="btn btn-primary btn-sm">
                    <i class="glyphicon glyphicon-search"></i> 查询
                </button>
                <button type="button" class="btn btn-info btn-sm reset">
                    <i class="glyphicon glyphicon-refresh"></i> 重置
                </button>
            </div>

        </form>
        <hr class="no-margin"/>
        <!-- 操作信息提示的地方 -->
        <div th:if="${remind}" class="alert alert-${ remind.level  }"
             th:classappend="'alert-' + ${remind.level}">
            <button data-dismiss="alert" class="close" type="button">
                <i class="glyphicon glyphicon-remove"></i>
            </button>
            <span th:remove="tag" th:utext="${ remind.message }"></span>
        </div>
        <!--列表栏-->
        <form class="nocol">

            <div class="action-bar">
                <a class="btn btn-sm btn-primary" th:href="@{/report/insert}" data-toggle="tooltip" title="新增日报, 不限制补填时间">
                    <i class="glyphicon glyphicon-plus"></i> 新增日报
                </a>
                <button type="button" class="btn btn-sm btn-info " data-toggle="tooltip" title="导出当前条件的日报,最多2000条"
                        onclick="common.exportReport(this)">
                    <i class="glyphicon glyphicon-export">导出查询</i>
                </button>
            </div>

            <table class="table table-striped  table-hover table-bordered stable" data-lookup=".lookup">
                <thead>
                <tr class="text-center">
                    <th>姓名</th>
                    <th class="sortable" data-column="date" th:classappend="${pager.lookup?.sortColumn == 'date'} ? ${pager.lookup?.sortOrder} : ''">
                        日期
                    </th>
                    <th class="sortable" data-column="jira" th:classappend="${pager.lookup?.sortColumn == 'date'} ? ${pager.lookup?.sortOrder} : ''">
                        JIRA
                    </th>
                    <th>项目</th>
                    <th class="sortable" data-column="duration" th:classappend="${pager.lookup?.sortColumn == 'duration'} ? ${pager.lookup?.sortOrder} : ''">
                    时间(分钟)
                    </th>
                    <th>内容</th>
                    <th class="text-info">操作</th>
                </tr>
                </thead>
                <tbody align="center">
                <!-- <c:forEach items="${ pager.datas}" var="cur" varStatus="status"> -->
                <tr th:each="cur:${pager?.datas}">
                    <td th:text="${cur.userName}" class="text-danger">张三</td>
                    <td><a title="查看详情" data-toggle="tooltip"
                           th:onclick="clickDate([[${cur.id}]])"
                           th:text="${cur.date}">2021-12-12</a></td>
                    <td>
                        <a class="text-success action-get" type="button"
                           th:attr="data-url='/jira/reportDetail/'+${cur.jira}"
                           data-toggle="tooltip"
                           title="jira工时详情"
                           data-confirm="进入工时详情页面会进行一次工时统计,确定查看jira工时详情吗?">
                            <th:block th:text="${cur.jira}"></th:block>
                            <i class="action-param" data-key="back" data-value="/report/"></i>
                        </a>
                    </td>
                    <td>
                        <a th:text="${#strings.abbreviate(cur.projectName,15)}"
                           th:onclick="common.reportTotalTime([[${cur.projectId}]])"
                           data-toggle="tooltip"
                           th:title="${cur.projectName}"></a>
                    </td>
                    <td th:text="${cur.duration}">100</td>
                    <td>
                        <a href="#" onclick="common.clickContent(this);" th:title="${cur.content}"
                           data-toggle="tooltip"
                           th:text="${#strings.abbreviate(cur.content,20)}">content</a>
                    </td>
                    <td>
                        <div class="btn-group-dis">
                            <a th:if="${cur.couldDelete}" class="btn btn-xs btn-warning "
                               th:href="@{'/report/update/'+${cur.id}}"
                               data-toggle="tooltip" title="编辑">
                                <i class="glyphicon glyphicon-edit"></i>
                            </a>
                            <button th:if="${cur.couldDelete}" class="btn btn-xs btn-danger action-get" type="button"
                                    th:attr="data-url='/report/delete/'+${cur.id}"
                                    data-toggle="tooltip"
                                    title="删除" data-confirm="确认删除本条记录吗">
                                <i class="glyphicon glyphicon-trash"></i>
                            </button>
                        </div>
                    </td>
                </tr>
                <!-- </c:forEach> -->
                </tbody>
            </table>

        </form>
        <!--页码相关-->
        <div th:replace="common/pager :: pager"></div>
    </div>


</div>

<!-- 引入通用js-->
<div th:replace="common/footer :: footer"></div>
<script>
    function clickContent(e) {
        let title = $(e).attr("data-original-title");
        $.alert({
            theme: 'bootstrap',
            title: '工作内容',
            content: '<p style="white-space: pre-wrap">' + title + '</p>'
        });
    }

    function clickDate(id) {
        $.alert({
            theme: 'bootstrap',
            title: '当日工作详情',
            columnClass: 'col-md-10 col-md-offset-1',
            content: "url:" + (ctx + "report/day/" + id)
        });
    }

</script>
</body>
</html>